﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class Login : System.Web.UI.Page
{
    DBClass dbobj = new DBClass();
    CommonClass ccobj = new CommonClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["Isdetail"] = 0;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = "";
        switch (DropDownList1.SelectedItem.Text.Trim())
        {
            case "系统管理员":
                str = "select * from Admin where AdminID='" + TextBox1.Text.Trim() + "'and PassWord='" + TextBox2.Text.Trim() + "'";
                break;
            case "辅导员":
                str = "select * from Teacher where TeacherID='" + TextBox1.Text.Trim() + "'and PassWord='" + TextBox2.Text.Trim() + "'";
                break;
            case "考评人员":
                str = "select * from Assess where AssessID='" + TextBox1.Text.Trim() + "'and PassWord='" + TextBox2.Text.Trim() + "'";
                break;
        }
        DataTable dstable = dbobj.GetDataSet(str, "tabUser");
        if (dstable.Rows.Count > 0)
        {
            Session["UserID"] = TextBox1.Text.Trim();
            Response.Write("<script>alert('登陆成功！')</script>");

            switch (DropDownList1.SelectedItem.Text.Trim())
            {
                case "系统管理员":
                    Response.Redirect("~/Manager/Notice.aspx");
                    break;
                case "辅导员":
                    Response.Redirect("~/Manager/Notice.aspx");
                    break;
                case "考评人员":
                    Response.Redirect("~/Manager/Notice.aspx");
                    break;
            }
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误！')</script>");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        DropDownList1.SelectedIndex = -1;
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Register.aspx");
    }
}